<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>

</html>
<script>
  function computed(str) {
    
    var newstr2 = ''
    for (var i = 0; i < str.length; i++) {
      if (str[i] == ' ') {
      } else {
        if (str[i] == '!') {
          newstr2 += '啊'
        } else if (str[i] == 'h') {
          newstr2 += 'H'
        } else if (str[i] == 'w') {
          newstr2 += 'W'
        } else {
          newstr2 += str[i]
        }
      }
    }
    let newstr1 = newstr2.split("").reverse().join('')
    return newstr1
  }
  console.log(computed(' hello world 我爱你!'));
</script>